import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * @Author YongQiang
 * @Date 2021/10/9 10:04
 * @Version 1.0
 */
public class DateString {
    public static void main(String[] args) {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        Calendar now = Calendar.getInstance();
        now.add(Calendar.MONTH, -1);
        now.set(Calendar.DAY_OF_MONTH, 1);
        Calendar end = Calendar.getInstance();
        end.add(Calendar.MONTH, -1);
        end.set(Calendar.DAY_OF_MONTH, end.getActualMaximum(Calendar.DAY_OF_MONTH));
        while (now.before(end)) {
            System.out.print(format.format(now.getTime()) + ",");
            now.add(Calendar.DAY_OF_MONTH, 1);
        }
        System.out.print(format.format(now.getTime()));
    }
}
